package com.example.secondhandsysapi.Service;

import com.example.secondhandsysapi.Entity.UserInfo;
import com.example.secondhandsysapi.Mapper.UserInfoMapper;
import com.example.secondhandsysapi.Vo.GenderCount;
import com.example.secondhandsysapi.Vo.VGC;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService{

    @Autowired
    private UserInfoMapper userInfoMapper;


    @Override
    public Integer LoginBackend(UserInfo userInfo) {
        return userInfoMapper.LoginBackend(userInfo);
    }

    //查询用户详细信息
    @Override
    public List<UserInfo> getUserDetailInfo() {
        return userInfoMapper.getUserDetailInfo();
    }

    @Override
    public UserInfo getUserDetailInfoByID(Integer user_id) {
        return userInfoMapper.getUserDetailInfoByID(user_id);
    }

    @Override
    public List<UserInfo> getUserDetailInfoByID1(Integer user_id) {
        return userInfoMapper.getUserDetailInfoByID1(user_id);
    }
    @Override
    public List<UserInfo> getUserDetailInfoByName(String user_name) {
        return userInfoMapper.getUserDetailInfoByName(user_name);
    }
    @Override
    public List<UserInfo> getUserDetailInfo1(Integer user_id, String user_name) {
        return userInfoMapper.getUserDetailInfo1(user_id,user_name);
    }


    //获取新增用户数量
    @Override
    public Integer findNewUser(Date registration_date) {
        Integer i =  userInfoMapper.findNewUser(registration_date);
        return i;
    }


    //获取用户修改的个人信息
    @Override
    public List<UserInfo> getAllUpdateUserInfo( Integer user_id, String user_name) {
        List<UserInfo> i=  userInfoMapper.getAllUpdateUserInfo(user_id, user_name);
        return i;
    }
    @Override
    public List<UserInfo> getAllUpdateUserInfo1() {
        return userInfoMapper.getAllUpdateUserInfo1();
    }
    @Override
    public List<UserInfo> getAllUpdateUserInfoByName(String user_name) {
        return userInfoMapper.getAllUpdateUserInfoByName(user_name);
    }
    @Override
    public List<UserInfo> getAllUpdateUserInfoById(Integer user_id) {
        return userInfoMapper.getAllUpdateUserInfoById(user_id);
    }


    //获取分页信息
    @Override
    public PageInfo<UserInfo> getUserInfo(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<UserInfo> i= userInfoMapper.getAllUpdateUserInfo(null,"");
        PageInfo<UserInfo> pageInfo = new PageInfo<>(i);
        return pageInfo;
    }

    //通过时修改用户状态
    @Override
    public Integer updateStatus(Integer user_id) {
        Integer i = userInfoMapper.updateStatus(user_id);
        return  1;
    }

    //拒绝时修改用户状态
    @Override
    public Integer updateCheck_Info(String check_info, Integer user_id) {
        Integer i=userInfoMapper.updateCheck_Info(check_info,user_id);
        return i;
    }

    //获取用户性别饼图
    @Override
    public List<VGC> getUserGenderCount() {
        return userInfoMapper.getUserGenderCount();
    }

    @Override
    public Integer insertUserInfo(UserInfo userInfo) {
        return userInfoMapper.insertUserInfo(userInfo);
    }

    //用户修改个人信息
    @Override
    public Integer updateUserInfo(UserInfo userInfo) {
        Integer i=userInfoMapper.updateUserInfo(userInfo);
        return  i;
    }


}